﻿using Microsoft.AspNetCore.Mvc.Filters;
using NanjingbeiRailwayStation.WebApi.Controllers;

namespace NanjingbeiRailwayStation.WebApi.ActionFilters
{
    /// <summary>
    /// 
    /// </summary>
    public class LoggingActionFilter : IActionFilter
    {
        private readonly ILogger<LoggingActionFilter> _logger;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logger"></param>
        public LoggingActionFilter(ILogger<LoggingActionFilter> logger)
        {
            _logger = logger;
        }
       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public void OnActionExecuted(ActionExecutedContext context)
        {

            _logger.LogInformation(context.HttpContext.Request.Path.ToString());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void OnActionExecuting(ActionExecutingContext context)
        {
            _logger.LogInformation( context.HttpContext.Request.Path.ToString());
          
        }
    }
}
